var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var stylus = require('gulp-stylus');
var jade = require('gulp-jade');
var coffee = require('gulp-coffee');
var gutil = require('gulp-util');


gulp.task('jade', function() {
  gulp.src('./wechat/static/index.jade')
    .pipe(sourcemaps.init())
    .pipe(jade())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./wechat/templates'))
});

gulp.task('coffee', function() {
  gulp.src('./wechat/static/js/*.coffee')
    .pipe(sourcemaps.init())
    .pipe(coffee({bare: true}).on('error', gutil.log))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./wechat/static/js'))
});

gulp.task('watch', function() {
    gulp.watch('./wechat/static/index.jade', ['jade']);
    gulp.watch('./wechat/static/js/*.coffee', ['coffee']);
});

gulp.task('default', ['jade', 'coffee', 'watch']);